package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.db.Question;
import com.itheima.mapper.QuestionMapper;
import com.itheima.service.db.QuestionService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @Author 请不要叫我高司令
 * @Date 2022/3/14 23:37
 * @Version 1.0
 */

@DubboService
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    private QuestionMapper questionMapper;

    @Override
    public Question findByUserId(Long userId) {
        LambdaQueryWrapper<Question> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Question::getUserId, userId);

        return questionMapper.selectOne(queryWrapper);
    }

    @Override
    public void Update(Question question) {
        questionMapper.updateById(question);
    }

    @Override
    public void save(Question question) {

        questionMapper.insert(question);

    }
}
